<?php

class Test_Abovo_Model_Auth extends Solar_Test {
    
    private $_auth;
    
    public function setup()
    {
        $this->_auth = Solar::factory('Abovo_Model_Auth');
    }
    
    public function testFetchByHandle()
    {
        $user = array(
            'handle'       => 'antti',
            'password'     => '123456789',
        );
        
        // insert user
        $this->_auth->insert($user);
        
        $out = $this->_auth->fetchByHandle('antti');
        
        $this->assertTrue($out instanceof Solar_Sql_Row);
        
        $out = $this->_auth->fetchByHandle('someone');
        $this->assertFalse($out);
    }
    
    public function testIsValidPassword()
    {
        // invalid
        $this->assertFalse($this->_auth->isValidPassword('antti', '12345678'));
        
        // valid
        $this->assertTrue($this->_auth->isValidPassword('antti', '123456789'));
        
        // handle doesn't exist
        $this->assertFalse($this->_auth->isValidPassword('nobody', '123456789'));
    }
}

